from flask import Flask
from . import settings
from flask_socketio import SocketIO


socketio = SocketIO()


def create_app(config_name="default") -> Flask:
    app = Flask(__name__)
    app.config.from_object(settings.config_dict[config_name])
    register_socketio(app)

    from .blueprints import index
    app.register_blueprint(index.index_bp)

    from .blueprints import real_time
    app.register_blueprint(real_time.rt_bp)


    return app


def register_socketio(app):
    socketio.init_app(app)